#!/bin/bash

# 1. 构建前端
npm install
npm run build

# 2. 拷贝dist到本地nginx挂载目录
NGINX_HTML_PATH="/Users/mac/Soft/docker/nginx/html"

if [ ! -d "$NGINX_HTML_PATH" ]; then
  echo "目标Nginx目录不存在，正在创建..."
  mkdir -p "$NGINX_HTML_PATH"
fi

rm -rf "$NGINX_HTML_PATH"/*
cp -r dist/* "$NGINX_HTML_PATH"/

# 3. 重启nginx容器（假设容器名为nginx）
echo "重启Nginx容器..."
docker restart nginx

echo "部署完成！请访问 http://localhost:8099" 